﻿--[[
    @brief    国际版登录处理
    @Author    matrixchen
    @date    2017-05-16
--]]

EOverseaLoginUI = 
{
    sOverseaLogin = "pnlOverseasLogin";
    sBtnLogin = "btnLogin";
    sBtnOthAcc  = "btnOtherAcc";
};

EOverseaLoginRes = 
{
};

TOverseaLogin = 
{
    -- 初始化
    InitView = function(dwRoot)
        TOverseaLogin.dwViewID = dwRoot;
    end;

    -- 卸载
    UnInitView = function()
        TOverseaLogin.pLoginUI = nil;
        TOverseaLogin.dwViewID = 0;
    end;

    -- 创建界面
    CheckUI = function(dwRoot)
        if nil ~= TOverseaLogin.pLoginUI then
            return true;
        end;

        local dwRoot = ui_utility.get_ctrl_id_by_path(TOverseaLogin.dwViewID, 
                                                EOverseaLoginUI.sOverseaLogin);

        TOverseaLogin.pLoginUI = ui_utility.get_ctrl_ptr_by_id(dwRoot);

        if nil == TOverseaLogin.pLoginUI then
            TGPLog.LogE("OverseaLogin", "Get login pannel fail.");
            return false;
        end;

        -- 切换帐号
        local dwTemp = ui_utility.get_ctrl_id_by_path(dwRoot, EOverseaLoginUI.sBtnOthAcc);

        if nil ~= dwTemp and 0 ~= dwTemp then
            ui_utility.setproperty_by_id(dwTemp, "OnClick", "TOverseaLogin.OnClkOther");
        else
            TGPLog.LogE("QKLogin", "Switch other account button is nil.");
        end;

        -- 点击登陆

        dwTemp = ui_utility.get_ctrl_id_by_path(dwRoot, EOverseaLoginUI.sBtnLogin);

        if nil ~= dwTemp and 0 ~= dwTemp then
            ui_utility.setproperty_by_id(dwTemp, "OnClick", "TOverseaLogin.OnClkLogin");
        else
            TGPLog.LogE("QKLogin", "click login button is nil.");
        end;

    end;


    ShowView = function()
        if TOverseaLogin.CheckUI() then
            TOverseaLogin.pLoginUI:Show(TRUE);
        else
            TGPLog.LogE("OverseaLogin", "Show view, pannel is null.");
        end;
    end;

    HideView = function()
        if nil ~= TOverseaLogin.pLoginUI then
            TOverseaLogin.pLoginUI:Show(FALSE);
        else
            TGPLog.LogE("OverseaLogin", "Hide view, pannel is null.");
        end;
    end;

    -- 使用其它帐号登录
    OnClkOther = function(pUILib, nCtrlID)    
        local     zParam = {};

        zParam["nPageIdx"] = ELoginPage.lpAccLogin;
        comm_center.call_service("Svr_SwitchLoginPage", zParam);
        --comm_center.call_service("SvrShowFacebook", {});
    end;

    OnClkLogin = function(pUILib, nCtrlID)
        comm_center.call_service("SvrShowFacebook", {});
    end;

    SetStatus = function(zParam)
    end;

    dwViewID = 0;
    pLoginUI = nil;        -- Login pannel

};